﻿using System.Windows;
using System.Windows.Media;
namespace TciNewsReader_2014_04.Controls
{
    public partial class SbTextContainer
    {
        public SbTextContainer()
        {
            InitializeComponent();
        }
        #region TextForeground (Attached DependencyProperty)
        public static readonly DependencyProperty TextForegroundProperty =
            DependencyProperty.RegisterAttached("TextForeground", typeof(Brush), typeof(SbTextContainer), new PropertyMetadata(OnTextForegroundChanged));
        public static void SetTextForeground(DependencyObject o, Brush value)
        {
            o.SetValue(TextForegroundProperty, value);
        }
        public static Brush GetTextForeground(DependencyObject o)
        {
            return (Brush)o.GetValue(TextForegroundProperty);
        }
        private static void OnTextForegroundChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SbTextContainer sbTextContainer = d as SbTextContainer;
            if (sbTextContainer != null)
            {
                sbTextContainer.Tb1.Foreground = e.NewValue as Brush;
            }
        }
        #endregion
        #region Text (DependencyProperty)
        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }
        public static readonly DependencyProperty TextProperty =
            DependencyProperty.Register("Text", typeof(string), typeof(SbTextContainer),
              new PropertyMetadata{PropertyChangedCallback = TextPropertyChanged});
        private static void TextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SbTextContainer sbTextContainer = d as SbTextContainer;
            if (sbTextContainer != null)
            {
                sbTextContainer.Tb1.Text = e.NewValue.ToString();
            }
        }
        #endregion
    }
}
